package simulation;

import java.util.Timer;
import java.util.TimerTask;

import maze.Location;
import pacman.Ghost;

public class DataCollector implements Runnable{

	int FPS;
	Ghost ghost;
	Location location;
	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}

	int ultrasonicRotation;
	public int getUltrasonicRotation() {
		return ultrasonicRotation;
	}

	public void setUltrasonicRotation(int ultrasonicRotation) {
		this.ultrasonicRotation = ultrasonicRotation;
	}

	public int ultrasonic;
	int light;
	int ir;
	int rotation;
	String name;
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getRotation() {
		return rotation;
	}

	public void setRotation(int rotation) {
		this.rotation = rotation;
	}

	Timer timer;
	
	public DataCollector(int FPS, final Ghost ghost){
		this.FPS = FPS;
		this.ghost = ghost;
		TimerTask dtcTask = new TimerTask() {
			@Override
			public void run() {
				setLocation(ghost.getLocation());
				setIr(ghost.getInfraredSensor().getLastReading());
				
				setLight(ghost.getLightSensor().getLastReading());
				int distance = ghost.getUltrasonicSensor().getLastReading();
				setUltrasonic(distance);
				setRotation(ghost.getRotation());
				setName(ghost.getName());
				setUltrasonicRotation(ghost.getSensorRotation());
			}
		};
		timer = new Timer();
		timer.schedule(dtcTask, 1000/FPS, 1000/FPS);	
		
	}

	public int getUltrasonic() {
		return ultrasonic;
	}

	public void setUltrasonic(int ultrasonic) {
		this.ultrasonic = ultrasonic;
		//System.out.println("ultra: " + ultrasonic);
	}

	public int getLight() {
		return light;
	}

	public void setLight(int light) {
		this.light = light;
	}

	public int getIr() {
		return ir;
	}

	public void setIr(int ir) {
		this.ir = ir;
	}
	
	public Ghost getGhost(){
		return ghost;
	}

	@Override
	public void run() {
		;//timer.start();
		
	}

}
